package com.ssy.lingxi.enhance.constant;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 生产通知单加工企业内部状态 - enum
 * @author fhj
 * @date 2020/10/22
 * @version 2.0.0
 */
public enum PNOProcessInnerStatusEnum {

    TO_BE_SUBMIT_EXAM(1, "待提交审核"),
    TO_BE_EXAM1(2, "待审核（一级）"),
    TO_BE_EXAM2(3, "待审核（二级）"),
    TO_BE_CONFIRM(4, "待确认"),
    ALREADY_CONFIRM(5, "已确认（接受）"),
    SUBMIT_NOT_PASSED(11, "提交审核不通过"),
    NOT_PASSED1(12, "审核不通过（一级）"),
    NOT_PASSED2(13, "审核不通过（二级）"),
    ALREADY_COMPLETE(21, "已完成"),
    TO_BE_ADD_DELIVERY(22, "待新增加工发货单"),
    TO_BE_EXAM_DELIVERY(23, "待审核加工发货单"),
    TO_BE_ADD_LOGISTICS(24, "待新增物流单"),
    TO_BE_CONFIRM_LOGISTICS(25, "待确认物流单"),
    TO_BE_CONFIRM_DELIVERY(26, "待确认发货"),
    ALREADY_CONFIRM_DELIVERY(27, "已确认发货"),
    TO_BE_CONFIRM_RECEIPT(28, "待确认回单"),
    NOT_ACCEPTED(29, "已确认（不接受）"),
    NOT_ACCEPTED_LOGISTICS(30, "不接受物流单"),
    ALREADY_DISCONTINUE(31, "已中止");

    private Integer code;
    private String message;

    PNOProcessInnerStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据code获取message
     * */
    public static String getMessage(Integer code) {
        PNOProcessInnerStatusEnum pnoProcessInnerStatusEnum = Arrays.stream(PNOProcessInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return pnoProcessInnerStatusEnum != null ? pnoProcessInnerStatusEnum.getMessage() : "无效状态";
    }

    /**
     * 获取加工企业待确认生产通知单列表状态集
     * */
    public static List<Integer> getProcessToBeConfirmListStatus() {
        return Stream.of(
                PNOProcessInnerStatusEnum.SUBMIT_NOT_PASSED.getCode(),
                PNOProcessInnerStatusEnum.NOT_PASSED1.getCode(),
                PNOProcessInnerStatusEnum.NOT_PASSED2.getCode(),
                PNOProcessInnerStatusEnum.TO_BE_CONFIRM.getCode()
        ).collect(Collectors.toList());
    }

    /**
     * 获取所有
     * */
    public static List<Map<String, Object>> getAll() {
        return Arrays.stream(PNOProcessInnerStatusEnum.values()).map(a -> {
            Map<String, Object> map = new HashMap<>();
            map.put("code", a.getCode());
            map.put("message", a.getMessage());
            return map;
        }).collect(Collectors.toList());
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
